package server

import (
	"log"
	"net"
	"net/http"

	"github.com/gorilla/mux"
	"github.com/spf13/viper"
)

func Run(r *mux.Router) {
	// start static file server
	StaticHTTPServer(r)

	host := viper.GetString("server.host")
	port := viper.GetString("server.port")

	addr := net.JoinHostPort(host, port)

	log.Println("Starting server on : ", addr)
	if err := http.ListenAndServe(addr, r); err != nil {
		log.Fatal(err)
	}
}
